<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class loginModel extends Model {

    private $table = '`sd_member`';

    public function addmember($data) {
        return $this->_insert($this->table, $data);
    }

    public function getOne($name) {
        return $this->_row("SELECT * FROM " . $this->table . " WHERE name = '{$name}'" );
    }
    public function checkpassoword($name,$password) {
        return $this->_row("SELECT * FROM " . $this->table . " WHERE name = '{$name}'and password='{$password}'" );
    }
    public function allmember(){
        return $this->_all("SELECT * FROM .$this->table");
    }
    public function getinfo($id){
        return $this->_row("SELECT * FROM " . $this->table . " WHERE member_id = {$id}");
    }
    public function updatemember($data){
        $where = "WHERE member_id = " . $_SESSION['userid'];
        Return $this->_update($this->table, $data, $where);
    }
    public function updatemember2($data,$id){
        $where = "WHERE member_id = {$id}";
        Return $this->_update($this->table, $data, $where);
    }
    public function friend($id){
        return $this->_all("SELECT * FROM .$this->table WHERE friend = {$id}");
    }
    
    public function pai2(){
        return $this->_all("SELECT * FROM sd_member order by wrank desc limit 7");
    }
    public function pai3(){
       return $this->_all("SELECT friend,COUNT(*) FROM sd_member GROUP BY friend ORDER BY COUNT(*) desc");
    }

}
